package com.itheima.web.controller.system;

import com.github.pagehelper.PageInfo;
import com.itheima.core.BaseServlet;
import com.itheima.domain.system.Dept;
import com.itheima.domain.system.SysLog;
import com.itheima.service.system.SysLogService;
import com.itheima.service.system.impl.SysLogServiceImpl;
import org.apache.commons.lang3.StringUtils;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/system/sysLog/*")
public class SysLogServlet extends BaseServlet {
    private SysLogService sysLogService = new SysLogServiceImpl();

    /**
     * 查看所有日志
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public String list(HttpServletRequest request, HttpServletResponse response)throws Exception{
        /*1.获取表单数据*/
        String pageNum = request.getParameter("pageNum");
        String pageSize = request.getParameter("pageSize");

        if(StringUtils.isBlank(pageNum)){
            pageNum = "1";
        }
        if(StringUtils.isBlank(pageSize)){
            pageSize = "5";
        }

        /*2.调用service*/
        PageInfo<SysLog> pageInfo = sysLogService.pageQuery(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
        /*3.回显数据*/
        request.setAttribute("page",pageInfo);
        return "/WEB-INF/pages/system/sysLog/list.jsp";

    }

}
